home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / System / XFD / Developer / Sources / ASM / HUFF.a < prev    next >
Encoding:
Text File  |  2001-09-16  |  2.7 KB  |  125 lines

  1. *******************************************************
  2. **    XFD external decruncher for HUFF Cruncher      **
  3. **        written by Mr. Larmer / Wanted Team        **
  4. **       shortened and fixed by SDI in 2000           **
  5. *******************************************************
  6.  
  7.         INCLUDE    "AINCLUDE:IncDirs.i"
  8.         INCLUDE    "libraries/xfdmaster.i"
  9.         INCLUDE "lvo/exec_lib.i"
  10.  
  11.         * head function for tests
  12. *        INCLUDE    "xfdExeHead.a"
  13.  
  14. ; xfdForeman structure MUST be first thing in all external decrunchers
  15.  
  16. ForeMan        moveq    #-1,d0        ;security
  17.         rts
  18.         dc.l    XFDF_ID        ;id
  19.         dc.w    1        ;version
  20.         dc.w    0
  21.         dc.l    0,0        ;private
  22.         dc.l    S_HUFF        ;first slave
  23.  
  24. **************************************************
  25.  
  26.         dc.b    "$VER: HUFF 2.0 (19.04.2000)",0
  27. N_HUFF        dc.b    "(HUFF) Data Cruncher",0
  28.         EVEN
  29.  
  30. **************************************************
  31.  
  32. ; xfdSlave structure: this one doesn't support segment decrunching
  33.  
  34. S_HUFF        dc.l    0        ;no more slaves
  35.         dc.w    2        ;version
  36.         dc.w    39        ;master version
  37.         dc.l    N_HUFF        ;name
  38.         dc.w    XFDPFF_DATA
  39.         dc.w    0
  40.         dc.l    RB_HUFF        ;recog buffer
  41.         dc.l    DB_HUFF        ;decrunch buffer
  42.         dc.l    0        ;recog segment
  43.         dc.l    0        ;decrunch segment
  44.         dc.w    0,0
  45.         dc.l    $408    * header, table, 1 long data
  46.  
  47. ;-------------------------------------------------
  48.  
  49. ; Recog buffer function: receives buffer + length in a0/d0
  50.  
  51. RB_HUFF        MOVEQ    #0,D0
  52.         CMP.L    #"HUFF",(A0)
  53.         BNE.B    .Exit
  54.         MOVEQ    #1,D0
  55. .Exit        RTS
  56.  
  57. ;-------------------------------------------------
  58.  
  59. ;Decrunch buffer function: receives bufferinfo in a0
  60.  
  61. DB_HUFF        movem.l    d2-d7/a2-a6,-(a7)
  62.         move.l    a0,a5
  63.         move.l    xfdbi_SourceBufLen(a5),d3
  64.         move.l    xfdbi_SourceBuffer(a5),a2
  65.         SUBA.L    A1,A1
  66.         MOVEA.L    A2,A0
  67.         MOVEQ    #1,D2
  68.         BSR.B    D_HUFF
  69.  
  70.         MOVE.L    A1,D0
  71.         move.l    d0,xfdbi_TargetBufSaveLen(a5)
  72.         move.l    d0,xfdbi_TargetBufLen(a5)
  73.         move.l    xfdbi_TargetBufMemType(a5),d1
  74.         MOVEA.L    xfdm_ExecBase(A6),A6
  75.         jsr    _LVOAllocMem(A6)
  76.         move.w    #XFDERR_NOMEMORY,xfdbi_Error(a5)
  77.         move.l    D0,xfdbi_TargetBuffer(a5)
  78.         beq.b    .Exit
  79.  
  80.         move.l    d0,a1
  81.         move.l    a2,a0
  82.         MOVEQ    #0,D2
  83.         bsr.s    D_HUFF
  84.  
  85.         moveq    #1,d0
  86. .Exit        movem.l    (a7)+,d2-d7/a2-a6
  87.         rts
  88.  
  89. **************************************************
  90.  
  91.         * A0 = input buffer
  92.         * A1 = output buffer
  93.         * D2 = test mode
  94.         * D3 = input size
  95. D_HUFF        MOVEM.L    D2-D7/A2-A6,-(A7)
  96.         LEA    4(A0),A6    * table data $404 byte
  97.         LEA    $404(A0),A0    * data start
  98.         SUB.L    #$404,D3    * size checks done in xfd structure!
  99.         MOVEQ    #0,D7
  100.         LEA    $200(A6),A5
  101.         MOVE.W    $1FE(A6),D4
  102. .mainloop    MOVE.W    D4,D5
  103. .lab1        DBRA    D7,.lab2
  104.         SUBQ.L    #4,D3
  105.         BMI.S    .end
  106.         MOVEQ    #31,D7
  107.         MOVE.L    (A0)+,D6
  108. .lab2        LSR.L    #1,D6
  109.         BCC.S    .lab3
  110.         MOVE.W    (A5,D5.W),D5
  111.         BPL.S    .lab1
  112.         BRA.S    .lab4
  113. .lab3        MOVE.W    (A6,D5.W),D5
  114.         BPL.S    .lab1
  115. .lab4        TST.L    D2
  116.         BNE.B    .testmode
  117.         MOVE.B    D5,(A1)+
  118.         BRA.S    .mainloop
  119. .testmode    ADDQ.L    #1,A1
  120.         BRA.B    .mainloop
  121. .end        MOVEM.L    (A7)+,D2-D7/A2-A6
  122.         RTS
  123.  
  124.         END
  125.